luci-base: revert timeout function argument for addNotification
authorFlorian Eckert <[email protected]>
Fri, 7 Mar 2025 12:49:04 +0000 (13:49 +0100)
committerFlorian Eckert <[email protected]>
Fri, 7 Mar 2025 13:38:36 +0000 (14:38 +0100)
The function signature changed and all function call to addNotification
that add a CSS class does not work anymore. A direct revert is not
possible.

If this feature is needed than a new function musst be added, that does
not break the function signature.

Fixes: 53e36e3293bee2ea2ce0fbc1250074c44cfe8335
Signed-off-by: Florian Eckert <[email protected]>
(cherry picked from commit 3f832f25120184a5794f593bafa762747d6cc693)

modules/luci-base/htdocs/luci-static/resources/ui.js

index 391d64a35449240523db7cba3af6b940db135eb7..fe46265449ddacb1c8afe9583d8780ae0b72e1a6 100644 (file)
@@ -3847,11 +3847,6 @@ const UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
         * to the `dom.content()` function - refer to its documentation for
         * applicable values.
         *       
-        * @param {int} [timeout]
-        * A millisecond value after which the notification will disappear
-        * automatically. If omitted, the notification will remain until it receives
-        * the click event.
-        *
         * @param {...string} [classes]
         * A number of extra CSS class names which are set on the notification
         * banner element.
@@ -3859,7 +3854,7 @@ const UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
         * @returns {Node}
         * Returns a DOM Node representing the notification banner element.
         */
-       addNotification(title, children, timeout, ...classes) {
+       addNotification(title, children, ...classes) {
                const mc = document.querySelector('#maincontent') ?? document.body;
                const msg = E('div', {
                        'class': 'alert-message fade-in',
@@ -3876,7 +3871,7 @@ const UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
                                        'class': 'btn',
                                        'style': 'margin-left:auto; margin-top:auto',
                                        'click': function(ev) {
-                                               fadeOutNotification(ev.target);
+                                               dom.parent(ev.target, '.alert-message').classList.add('fade-out');
                                        },
 
                                }, [ _('Dismiss') ])
@@ -3892,27 +3887,6 @@ const UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
 
                mc.insertBefore(msg, mc.firstElementChild);
 
-               function fadeOutNotification(element) {
-                       const notification = dom.parent(element, '.alert-message');
-                       if (notification) {
-                               notification.classList.add('fade-out');
-                               notification.classList.remove('fade-in');
-                               setTimeout(() => {
-                                       if (notification.parentNode) {
-                                               notification.parentNode.removeChild(notification);
-                                       }
-                               });
-                       }
-               }
-
-               if (typeof timeout === 'number' && timeout > 0) {
-                       setTimeout(() => {
-                               if (msg && msg.parentNode) {
-                                       fadeOutNotification(msg);
-                               }
-                       }, timeout);
-               }
-
                return msg;
        },